import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

// 查询任务列表
export const queryInspectTask = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/inspectTask/queryPage", {
    data
  });
};

// 查询任务状态
export const queryTaskStatus = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/inspectTask/getTaskStatusList", {
    data
  });
};

// 查询任务详情
export const queryTaskDetail = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/get/${data}`);
};

// 巡检任务-根据区域查询巡检项详情
export const queryTaskItem = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/inspectTask/getItem", { data });
};

// 领取巡检任务
export const collectTask = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/pullTask/${data}`);
};

// 巡检任务-保存任务巡检项
export const saveTask = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/inspectTask/saveTaskItemResult", {
    data
  });
};

// 取消巡检任务
export const cancelTask = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/cancel/${data}`);
};

// 保存巡检任务
export const saveTaskItemResult = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/saveTaskItemResult`, {
    data
  });
};
// 提交巡检任务
export const submitTask = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/submitTask`, { data });
};

// 转派巡检任务
export const transferTask = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/inspectTask/transferTask`, {
    data
  });
};

/**
 * 巡检任务-签到
 * @param {object} params 查询任务巡检项
 * @param {string} params.factoryId
 * @param {string} params.facCode
 * @param {string} params.taskCode 任务编码
 * @param {string} params.inspectArea 巡检区域
 * @returns
 */
export function inspectAreaSignIn(data) {
  return http.post(`/digitaltwins/api/v1/inspectTask/inspectAreaSignIn`, { data });
}
/**
 * 巡检任务-历史超标值
 * @param {object} params 查询历史点位值
 * @param {string} params.factoryId
 * @param {string} params.facCode
 * @param {string} params.taskCode 任务编码
 * @param {string} params.meterReadingPoint 抄表点位
 * @returns
 */
export function historicalPoint(data) {
  return http.post(`/digitaltwins/api/v1/inspectTask/historicalPoint`, { data });
}
